home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group96b.txt
/
000051_icon-group-sender _Wed Nov 6 17:29:28 1996.msg
< prev
next >
Wrap
Internet Message Format
|
1997-01-02
|
1KB
Received: by cheltenham.cs.arizona.edu; Wed, 6 Nov 1996 16:41:39 MST
To: icon-group@cs.arizona.edu
Date: 6 Nov 1996 17:29:28 GMT
From: stephen@lila.york.ac.uk (stephen parker)
Message-Id: <55qhto$66r@netty.york.ac.uk>
Organization: a loss for words
Sender: icon-group-request@cs.arizona.edu
Subject: sets and structures
Errors-To: icon-group-errors@cs.arizona.edu
i'm reading ``An Overview of the Icon Programming Language; Version 8''
(Griswold). the section on sets says: ``insert(S, x) has no effect if x
is already in S''.
this appears to work for atomic types eg,
procedure main()
local l, s
s := set()
while(l := read()) do
insert(s, l)
every l := !s do
write(l)
end
however, if if i try to insert a structure then it never fails,
record rec(a,b)
procedure main()
local l, s
s := set()
while(l := read()) do {
a := l[1]
b := l[2:0]
insert(s, rec(a,b))
}
every l := !s do
write(l.a, " ", l.b)
end
results in output like:
; structest
foo
bar
bar
spam
b ar
s pam
f oo
b ar
;
as you would expect for a list rather than a set. so, what's the answer
if you want to form a set of non-atomic types? do i have to do it by
hand?
i suppose the answer is to buy the book -- i will when i have chance.
stephen